import React,{useState,useEffect} from 'react';
import { Button } from 'antd-mobile';
import { BrotherStore } from '../../../store/index';
import { sendBrotherTwo } from '../../../store/action';
export default function ReactChild (props){
    const [reduxSendTwo,changeReduxSendTwo] = useState(BrotherStore.getState());
    BrotherStore.subscribe(()=>{
     
        changeReduxSendTwo(BrotherStore.getState())
    })
    return(
        <div style={{marginTop:'10px'}}>
            <p>{props.brother}</p>
            <br/>
            <p>{'redux传递---'+reduxSendTwo}</p>
            <Button onClick={()=>{props.onClick()}}  style={{marginTop:'20px'}} className="btn" size="small" type="primary">通过父级传给兄弟一</Button>
            <Button onClick={()=>{  BrotherStore.dispatch(sendBrotherTwo('我是从兄弟二过来的')) }}  style={{marginTop:'20px'}} className="btn" size="small" type="primary">redux传值兄弟一</Button>
        </div>
    )
}